﻿using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace HML.Design
{
    /// <summary>
    /// LoadWait控件设计模式行为
    /// </summary>
    public class LoadWaitDesigner : ControlDesigner
    {
        public override SelectionRules SelectionRules
        {
            get
            {
                return base.SelectionRules & ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable | SelectionRules.LeftSizeable | SelectionRules.RightSizeable);
            }
        }

        protected override void OnPaintAdornments(PaintEventArgs pe)
        {
            base.OnPaintAdornments(pe);

            // 绘制虚线边框
            Control control = this.Control;
            Rectangle clientRectangle = control.ClientRectangle;
            Pen pen = new Pen((double)control.BackColor.GetBrightness() >= 0.5 ? ControlPaint.Dark(control.BackColor) : ControlPaint.Light(control.BackColor));
            pen.DashStyle = DashStyle.Dash;
            --clientRectangle.Width;
            --clientRectangle.Height;
            pe.Graphics.DrawRectangle(pen, clientRectangle);
            pen.Dispose();
        }
    }
}
